<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
	<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
<script type="text/javascript" src="${approot}/resource/jquery/validate/jquery.validate.js"></script>
   <link href="${approot}/resource/jquery/validate/jquery.validate.css" rel="stylesheet" type="text/css" />
   <link href="${approot}/resource/jquery/validate/style.css" rel="stylesheet" type="text/css" />
   
     <script type="text/javascript">
            /* <![CDATA[ */
            jQuery(function(){
                jQuery("#xuhao").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "编号不能为空"
                });
                jQuery("#stationName").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "进气地点不能为空"
                });    
                jQuery("#carNum").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "车号不能为空"
                });   
                jQuery("#carUser").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "司机不能为空"
                }); 
                jQuery("#dunwei").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "吨位不能为空"
                }); 
                jQuery("#price").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "进气单价不能为空"
                }); 
                jQuery("#enterDate").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "炼油厂装车时间不能为空"
                });   
                jQuery("#kaipiaoren").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "开票人不能为空"
                });   
                jQuery("#money").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "金额不能为空"
                });   
                
                jQuery("#xie").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "卸车地点不能为空"
                });    
                jQuery('#item').validated(function(){
					//alert("通过验证");
					do_add();
				});
            });
            /* ]]> */
        </script>
        
        <script type="text/javascript">
        function do_add()
        {   
            var str=$('#item').serializeObject();
            var jsons = $.toJSON(str);
            add_role(jsons);
        }


        function add_role(jsons){
 	       $.ajax({
 		   	url:'${approot}/admin/gasrecord/add',
 		   	dataType: 'json',
 		   	contentType: 'application/json',
 			data:jsons,
 			type:'post',
 			beforeSend:function(){
 			  // $('#main').disabled='true';
 			},
 			error:function(request){
 				//alert(S);
 			},
 			success:function(data){
 			   if(data.msg=="error")
 			   {
 	 			   alert('记录已经存在,请重新输入');
 			   }
 			   if(data.msg=="succ")
 			   {
 				  alert('添加成功');
 				 location.href="${approot}/admin/gasrecord/list/menu/0";
 			   }
 			}
 		   });
 	}
        </script>
   
</head>  
  <body style="background:#E8F5FE; padding:15px 18px;" class="scroll_r">
<div id="right_w"><p>当前位置：天然气、液化气进销存系统 >>添加进气记录</p></div>

<form method="post" action="${approot}/admin/user/add" id="item">
  <table border="0" cellpadding="0" cellspacing="1" width="92%" align="center" class="tab_l">
    <tr>
      <td><b>请按要求填写：</b></td>
      <td align="right">带<span style="color:#ff0000;">*</span>为必填</td>
    </tr>
  </table>
  <table border="0" cellpadding="0" cellspacing="1" width="92%" align="center" id="add_tab">
  
  <tr>
   <th><span style="color:#ff0000; margin:0;">*</span>编号：</th>
   <td><input type="text" id="xuhao" name="xuhao" value=""></td>
   <th>进气地点：</th>
   <td><input type="text" name="stationName" id="stationName"></td>
  </tr>
  <tr>
   <th>车号：</th>
   <td><input type="text" name="carNum" id="carNum"></td>
    <th>司机：</th>
   <td><input type="text" name="carUser" id="carUser"></td>
  </tr>
  
   <tr>
   <th>吨位数：</th>
   <td><input type="text" name="dunwei" id="dunwei"></td>
    <th>进气单价：</th>
   <td><input type="text" name="price" id="price"></td>
  </tr>
  <tr>
   <th><span style="color:#ff0000; margin:0;">*</span>炼油厂装车时间：</th>
   <td><input type="text" id="enterDate" name="enterDate" class="Wdate" onFocus="WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"/> </td>
   <th>开票人：</th>
   <td><input type="text" name="kaipiaoren" id="kaipiaoren"></td>
  </tr>
  <tr>
   <th><span style="color:#ff0000; margin:0;">*</span>金额：</th>
   <td><input type="text" id="money" name="money" value=""></td>
   <th>卸车地点：</th>
   <td><input type="text" name="xie" id="xie"></td>
  </tr>
 
 </table>
  <p id="tab_but">
   <input type="submit" value="提 交">
   <input type="button" value="返回" onclick="history.go(-1)">
   </p>
</form>
</body>
</html>
